package com.scu.service;

import com.scu.dao.MessageDao;
import com.scu.pojo.Message;
import com.scu.pojo.MessageSearch;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional
public class MessageServiceImpl implements MessageService {
    @Autowired
    private MessageDao messageDao;


    /**
     * 获取所有的部门信息
     * @return
     */
    @Override
    public List<Message> checkMessage(MessageSearch info) {

        return messageDao.checkMessage(info,info.getPage()-1,info.getLimit());
    }

    @Override
    public int markReadMessage(int u_id) {
        return messageDao.markReadMessage(u_id);
    }

    @Override
    public int deleteMessage(int u_id, int m_id) {
        return messageDao.deleteMessage(u_id,m_id);
    }

    @Override
    public int responseMessage(int m_writer_id, int m_receiver_id, String m_content) {
        return messageDao.responseMessage(m_writer_id, m_receiver_id, m_content);
    }

    @Override
    public List<Message> checkUndeliveredMessage(int u_id) {
        return messageDao.checkUndeliveredMessage(u_id);
    }

    @Override
    public int sentUndeliveredMessage(int u_id, int m_id) {
        return messageDao.sentUndeliveredMessage(u_id,m_id);
    }

    @Override
    public List<Message> checkMessageByPage(MessageSearch info) {
        return messageDao.checkMessageByPage(info,info.getPage()-1,info.getLimit());
    }

    @Override
    public int getMessageCount(MessageSearch info) {
        return messageDao.getMessageCount(info);
    }

    @Override
    public List<Message> checkUndeliveredMessageByPage(MessageSearch info) {
        return messageDao.checkUndeliveredMessageByPage(info,info.getPage()-1,info.getLimit());
    }

    @Override
    public int getUndeliveredCount(MessageSearch info) {
        return messageDao.getUndeliveredMessageCount(info);
    }
}
